package com.gamejelly.broker.config;

import com.alipay.remoting.ConnectionEventType;
import com.gamejelly.broker.processor.event.DisconnectHandler;
import com.gamejelly.broker.processor.message.RegisterHandler;
import com.gamejelly.broker.processor.message.ServerRpcHandler;
import com.gamejelly.broker.server.BrokerServer;


public class EmbeddedServer {

    public static BrokerServer brokerServer(int port) {
        return BrokerServer.builder()
                .port(port)
                .addMessageProcessor(new ServerRpcHandler())
                .addMessageProcessor(new RegisterHandler())
                .addConnEventProcessor(ConnectionEventType.CLOSE, new DisconnectHandler())
                .Build();
    }
}
